package org.dtrd.config.wechat.entity.bean.officialaccount.template;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.dtrd.common.util.DateUtils;
import org.dtrd.config.wechat.config.WechatUtil;
import org.dtrd.config.wechat.entity.bean.officialaccount.WechatOaTemplateMsg;
import org.dtrd.config.wechat.entity.bean.officialaccount.WechatTemplateMiniProgram;

/**
 * 打卡成功推送消息
 *
 * @author xiao
 * @date 2022/8/7 10:14 PM
 */
@Data
@Slf4j
public class SigninSuccessMsg extends WechatOaTemplateMsg {

    /**
     * 打卡主题
     */
    private String signinName;
    /**
     * 打卡主题
     */
    private String signinState = "已打卡";
    /**
     * 打卡主题
     */
    private String signinTime;


    public static final class SigninSuccessMsgBuilder {
        private SigninSuccessMsg signinSuccessMsg;

        private SigninSuccessMsgBuilder() {
            signinSuccessMsg = new SigninSuccessMsg();
        }

        public static SigninSuccessMsgBuilder singleInstance() {
            return new SigninSuccessMsgBuilder();
        }

        public SigninSuccessMsgBuilder withMsgTitle(String msgTitle) {
            signinSuccessMsg.setMsgTitle(msgTitle);
            return this;
        }

        public SigninSuccessMsgBuilder withUrl(String url) {
            signinSuccessMsg.setUrl(url);
            return this;
        }

        public SigninSuccessMsgBuilder withMiniProgram(WechatTemplateMiniProgram miniProgram) {
            signinSuccessMsg.setMiniProgram(miniProgram);
            return this;
        }

        public SigninSuccessMsgBuilder withRemark(String remark) {
            signinSuccessMsg.setRemark(remark);
            return this;
        }

        public SigninSuccessMsgBuilder withMsgTime(String msgTime) {
            signinSuccessMsg.setMsgTime(msgTime);
            return this;
        }

        public SigninSuccessMsgBuilder withReceiverOpenIdArray(String[] receiverOpenIdArray) {
            signinSuccessMsg.setReceiverOpenIdArray(receiverOpenIdArray);
            return this;
        }

        public SigninSuccessMsgBuilder withSigninName(String signinName) {
            signinSuccessMsg.setSigninName(signinName);
            return this;
        }

        public SigninSuccessMsgBuilder withSigninTime(String signinTime) {
            signinSuccessMsg.setSigninTime(signinTime);
            return this;
        }

        public SigninSuccessMsg build() {
            return signinSuccessMsg;
        }


        /**
         * 打卡成功
         *
         * @param signinName 打卡项名称
         * @param signinTime 打卡时间
         * @param patientId
         * @return 我们已经收到您的打卡了，非常棒！
         * 打卡主题：打卡项目
         * 打卡状态：已打卡
         * 打卡时间：2020/02/21 10:10
         * 请耐心等待医师团队的反馈，请继续坚持打卡
         */
        public SigninSuccessMsg buildSigninSuccessMsg(String signinName, String signinTime, Integer patientId) {
            this.withMsgTitle("我们已经收到您的打卡了，非常棒！").withSigninName(signinName)
                    .withMsgTime(signinTime)
                    .withRemark("请耐心等待医师团队的反馈，请继续坚持打卡");
            log.info("SigninSuccessMsgBuilder.buildSigninSuccessMsg.[signinName={}, signinTime={}, patientId={}", signinName, signinTime, patientId);
            return this.build();
        }
    }
}
